import {
  createRouter,
  createWebHashHistory as createHistory,
} from "vue-router";
// import children from "./router";

const router = createRouter({
  history: createHistory(),
  routes: [
    {
      path: "/",
      name: "index",
      components: {
        // default表示默认
        default: () => import("../view/Home/index.vue"),
        demo: () => import("../view/Home/index.vue"),
      },
    },
    {
      path: "/login",
      name: "login",
      components: {
        // default表示默认
        default: () => import("../view/Login/index.vue"),
        demo: () => import("../view/Login/index.vue"),
      },
    },
  ],
});

// // beforeEach一般用来做前端登录判断
// router.beforeEach((to, from, next) => {
//   console.log("跳转之前");
//   // if (!localStorage.getItem('userinfo').token) {
//   //     if (to.name != 'login') {
//   //         router.push('/login');
//   //         return next()
//   //     }
//   // }
//   next();
// });

// router.afterEach((to, from) => {
//   console.log("跳转之后", to);
// });

export default router;
